DEFINITION MODULE SYSTEMX;       (* H. SEILER 31.03.82 *)
                                 (* UPDATED   05.01.83 *)

(*      File name:  SYSTEMX.def                                 *)
(*      Creation :  Orginal ETH FILE                            *)
(*      Function :  Interface to SYSTEMX                        *)
(*      By       :  ETH                                         *)
(*                                                              *)

(*
*    Copyright (c) 1985,1986,1987,1988,1989 by
*    ana-systems, Foster City, California.
*    All Rights Reserved.
*
*    This software is furnished under a license and may be used and copied
*    only  in accordance with  the  terms  of  such  license and  with the
*    inclusion of the above copyright notice.  This software or  any other
*    copies thereof may not be provided or otherwise made available to any
*    other  person.   No title to and ownership of the  software is  herby
*    transferred.
*
*    The information in this software is  subject to change without notice
*    and  should  not be construed as a commitment by ana-systems.   No
*    warranty is implied or expressed.
*
*   SCCID  = "%R%.%L%    %G%"; 
*)
(*      History of modifcation                                  *)
(*      Date            Who             Why                     *)
(*      6/23/85         Morris          ErrorNumber is added    *)
(*      01/09/96        K.Y.            CR = CHR(10)            *)
(*      08/04/86        Elias           Changes for the lovely ATARI     *)
(*      10-11/88        Wayne           More changes for Atari  *)
(*                                                              *)

(*  DEFINITION MODULE 'SYSTEMX' FOR MC68000/MC68020 RUNTIME      *)
(*  SYSTEM OF SMILER-2 CROSS COMPILER/CROSS LINKER SYSTEM.       *)
(*                                                               *)
(*                     VERSION 3.0                               *)
(*                                                               *)
(*                                                               *)
(*  THIS MODULE IS A COLLECTION OF ROUTINES TO SUPPORT CODE      *)
(*  GENERATED BY THE SMILER-2 CROSS COMPILER FOR THE MOTOROLA    *)
(*  MC68000/MC68020 PROCESSORS.                                  *)
(*                                                               *)
(*  SOME OF THESE ROUTINES SUCH AS NEWPROCESS ARE CALLED         *)
(*  EXPLICITELY BY AN USER PROGRAM, WHEREAS OTHER ROUTINES       *)
(*  (E.G. THE CASE-STATEMENT-PROCESSOR) ARE CALLED IMPLICITELY   *)
(*  BY THE CROSS COMPILER.                                       *)
(*                                                               *)
(*  THE SEQUENCE (ORDER) OF THE DEFINITIONS OF THE PROCEDURE     *)
(*  HEADERS IN THIS DEFINITION MODULE IS ESSENTIAL AND MUST      *)
(*  NOT BE CHANGED. THE COMPILER USES THE ORDINAL NUMBER OF      *)
(*  A SPECIFIC PROCEDURE WITHIN THIS MODULE AS A REFERENCE       *)
(*  TO THE MODULE 'SYSTEMX'.                                     *)
(*                                                               *)
(*  NOTE THAT MOST OF THE PROCEDURES HAVE A NON-STANDARD         *)
(*  PARAMETER-TRANSMISSION TO BE MORE EFFICIENT.                 *)
(*                                                               *)
(*  THIS MODULE HAS BEEN WRITTEN IN MODULA-2 TO FACILITATE       *)
(*  THE INSTALLATION AND USE OF SMILER-2 AT AN OTHER SITE        *)
(*  WITHOUT THE NEED OF AN (CROSS) ASSEMBLER.                    *)
(*                                                               *)
(*  USE THE FOLLOWING INSTALLATION PROCEDURE :                   *)
(*                                                               *)
(*  COMPILE THE DEFINITION MODULE FIRST, SAVE THE SYM-FILE.      *)
(*  THEN COMPILE THE IMPLEMENTATION MODULE USING THE SYMBOL      *)
(*  FILE GENERATED AND SAVE THE LNK-FILE.                        *)
(*  THE RESULTING LNK-FILE IS THEN THE (SEPARATELY COMPILED)     *)
(*  MODULE 'SYSTEMX'. THIS LNK-FILE MUST ALWAYS BE SUPPLIED      *)
(*  TO THE CROSS LINKER FOR A LINKER RUN.                        *)
(*                                                               *)
(*  NOTE : THE NAME OF THIS MODULE HAS EXACTLY TO BE 'SYSTEMX'   *)
(*  ----   (CAPITAL LETTERS ONLY), BECAUSE THE CROSS LINKER      *)
(*  LOOKS FOR A MODULE WITH THIS NAME WHEN THE TARGET PROCESSOR  *)
(*  IS MC68000 OR MC68020.                                       *)
(*                                                               *)

  FROM SYSTEM IMPORT ADDRESS, PROCESS;

  FROM GEMDOS IMPORT
                 ciPermissionNum,
                 ciORDONLY, ciOWRONLY, ciORDWR, ciONDELAY, ciOAPPEND,
                 ciOCREAT,  ciOTRUNC,  ciEXCLU, ciOCONTIG,
                 ciSTDIN ,  ciSTDOUT , ciSTDERR ;

  EXPORT QUALIFIED

     COPYRIGHT,
     CASEX, HALTX, STACKTEST,
     NEWPROCESS, TRANSFER, IOTRANSFER, SYSCALL,
     MULU32, DIVU32, MULS32, DIVS32,MERROR,Merrno,ARGC,ARGV,
     ieeeadd, ieeesub, ieeemul, ieeediv, ieeecmp, ieeetst, 
     ieeefloat, ieeetrunc, 
     skydiv,skycmp,skytst,skyfloat,skytrunc,
     ARGSTRING,Mexit,Mwrite,Mread,Mopen,Mclose,
     Misatty,
     Mfork,Mexeclp,Mwait, PZero,MZero,PInfinity,MInfinity,NaNu,
     Mcreat,Munlink,Mmalloc,Mfree,Mlseek,Mrename,Mmkdir,Mrmdir,single,
     ieeeunpack, MODES,Rmode,Imode,RoundModes,Execptions ,ExeMode,EofLineChar,
     LfChar,ORDONLY, OWRONLY, ORDWR, ONDELAY, OAPPEND, OCREAT, OTRUNC, 
     EXCLU, OCONTIG , STDIN  , STDOUT , STDERR, PermissionNum ;



CONST

  (* Error Message for Supportting Routines               *)
  COPYRIGHT = '(C) Copyright 1985-86 Djavaheri Bros. Modula-2/68';

   ORDONLY = ciORDONLY;
   OWRONLY = ciOWRONLY;
   ORDWR   = ciORDWR;
   ONDELAY = ciONDELAY;
   OAPPEND = ciOAPPEND;
   OCREAT  = ciOCREAT;
   OTRUNC  = ciOTRUNC;
   EXCLU   = ciEXCLU;
   OCONTIG = ciOCONTIG ;
   PermissionNum = ciPermissionNum;
  
  STDIN  = ciSTDIN  ;                   (* For Unix Standard Input *)
  STDOUT = ciSTDOUT ;                   (* For Unix Standard Output *)
  STDERR = ciSTDERR ;                   (* For Unix Standard error *)

   EofLineChar = 15C;   (* CR *)
   LfChar      = 12C;   (* LF *)

  PZero     = 0 ;
  MZero     = 80000000H; 
  PInfinity = 7F800000H;
  MInfinity = 0FF800000H;
  NaNu      = 7FFFFFFFH;
  OverflowFraction = 00FFFFFFH;
  

TYPE
(*
    Range Values for unpacked fields of Single operation                *)

   experange = [-128..127];
   singrange = [-1..0];

(* Rounding Modes nesseary for IEEE. The default is set by SYSTEMX to 
   Round to Nearset.
  
        IF A op B --> Z and  A<= Z <= B then                            *)

   RoundModes = ( Rplus, Rminus,Rzero,Rnear);

(* Infinity types: Either plus or Minus or None                         *)
   

   InfinityModes = (Affine,Projective);
   

(* 
   Execption which can be rasised by any of the operation. This Exection 
   are default seting in SYSTEMX.                                       *) 

   Execptions = ( InExResult,UnderFlow,OverFlow,DividByZero,InVaildOp);

(* Execption states:
   Such as Traping mode is disable or inable. Current mode of the operation
   and procedure to call. 

 *)
   ExeMode = RECORD
        trap : BOOLEAN;
        mode : BOOLEAN;
        errno : INTEGER;
        ProcName : PROCEDURE  ;
     END;

(* Single format extenated to unpacked format.
                                                                        *) 
   single = RECORD
       sign : singrange;
       exponent : experange ;
       fraction: BITSET;
   END (* single *);
   
 (* Error Code  from O/s to Modula-2/68                                 *)

   MERROR = ( OK,EndOfFile,IOError,NoFile,NoInodes,NoLus,BadOpenModes,NotOwner,
              NotOpenFile,BadFileName, NoSpace,NotaDirectory,MissingDirectory,
              FileIsDirectory,WritingToDirectory,NotaDevices,NoMoreSwap,
              FileIsBusy,BadSystemCall,NoReadPremission,NoWritePremission,
              NoSuchProcess, InteruptedCall,ArgListTooBig, ExecFormatErr,
              NotEnoughCore,NoChildren,NoMoreProces, BadAddress,BlockDeviceOnly,
              MountDeviceBusy,CrossDeviceLink,InvaildArgument,NotaTypeWriter,
              FileTooLarge,IllegalSeek,TooManyLink,BrokenPipe,OpWillBlock,
              BadLunNumber,NoAccess,FileSystemReadOnly,FileExits,Unkown);
                   

  VAR 

   ARGC : CARDINAL;
   ARGV : ADDRESS;      
   Merrno : MERROR;
   
  (* UTILITIES SUPPORTING THE COMPILER *)

  PROCEDURE CASEX;
  PROCEDURE HALTX;
  PROCEDURE STACKTEST;

  (* PSEUDO-MODULE SYSTEM *)
  PROCEDURE NEWPROCESS (PROCESSCODE : PROC;
                        FWAWSP : ADDRESS; LENGTHWSP : ADDRESS;
                        VAR PROCESSDESCRIPTOR : PROCESS;
                        INITIALPRIO : ADDRESS);
  PROCEDURE TRANSFER;
  PROCEDURE IOTRANSFER;
  PROCEDURE SYSCALL;

  (* 32-BIT (LONG-) INTEGER/CARDINAL ARITHMETIC *)
  PROCEDURE MULU32     (MULTIPLICAN, MULTIPLIER : ADDRESS);
  PROCEDURE DIVU32     (DIVIDEND, DIVISOR       : ADDRESS);
  PROCEDURE MULS32     (MULTIPLICAN, MULTIPLIER : ADDRESS);
  PROCEDURE DIVS32     (DIVIDEND, DIVISOR       : ADDRESS);

  (* 32-BIT IEEE FLOATING POINT FORMAT ARITHMETIC *)
 
  PROCEDURE ieeeadd       (op1,       op2     : BITSET):BITSET;
  PROCEDURE ieeesub       (op1,     op2 : BITSET):BITSET;
  PROCEDURE ieeemul       (op1, op2 : BITSET):BITSET;
  PROCEDURE ieeediv       (op1,   op2    : BITSET):BITSET;
  PROCEDURE ieeecmp       (op1, op2     : BITSET):INTEGER;
  PROCEDURE ieeetst       (op1                  : BITSET);
  PROCEDURE ieeefloat     (op1               : INTEGER):BITSET;
  PROCEDURE ieeetrunc     (op1               : BITSET):INTEGER;
  PROCEDURE skydiv        (op1,   op2    : BITSET):BITSET;
  PROCEDURE skycmp        (op1,op2        :BITSET):INTEGER;
  PROCEDURE skytst        (op1:                 BITSET):INTEGER;
  PROCEDURE skyfloat      (op1:          ADDRESS):REAL;
  PROCEDURE skytrunc      (op1:        REAL):ADDRESS;


  PROCEDURE ARGSTRING(ac:CARDINAL):ADDRESS;
  PROCEDURE Misatty(lun:CARDINAL):BOOLEAN;
  PROCEDURE Mexit (x:INTEGER);
  PROCEDURE Mwrite(count:INTEGER;buffer: ADDRESS;lu :INTEGER):INTEGER;
  PROCEDURE Mread (count:INTEGER;buffer: ADDRESS;lu :INTEGER):INTEGER;
  PROCEDURE Mlseek (offset:INTEGER;count: INTEGER;lu :INTEGER):INTEGER;
  PROCEDURE Mclose(lun:CARDINAL):INTEGER;
  PROCEDURE Mopen(Modes,Oflag:INTEGER;path:ADDRESS):INTEGER;
  PROCEDURE Mcreat(Oflag:INTEGER;path:ADDRESS):INTEGER;
  PROCEDURE Mmkdir(Oflag:INTEGER;path:ADDRESS):INTEGER;
  PROCEDURE Munlink(path:ADDRESS):INTEGER;
  PROCEDURE Mrmdir(path:ADDRESS):INTEGER;
  PROCEDURE Mrename(newpath,oldpath:ADDRESS):INTEGER;
  PROCEDURE Mmalloc(count:CARDINAL):ADDRESS;
  PROCEDURE Mfree(buff:ADDRESS):INTEGER;
  PROCEDURE Mfork():INTEGER;
  PROCEDURE Mwait(VAR status :INTEGER):INTEGER;
  PROCEDURE Mexeclp(arg6,arg5,arg4,arg3,arg2,arg1,arg0,
                progname: ADDRESS):INTEGER;
  PROCEDURE ieeeunpack(VAR op1:BITSET;VAR result:single):INTEGER;
VAR

  MODES : ARRAY [InExResult..InVaildOp] OF ExeMode;
  Rmode : RoundModes;
  Imode : InfinityModes;

END (* DEFINITION MODULE *) SYSTEMX.
